package com.tx.springboot_demo.controller;

import com.tx.springboot_demo.domain.IndexDomain;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import java.util.ArrayList;
import java.util.List;


/**
 * @author tx
 * @description  测试thymeleaf在template下，但是在配置了jsp和thymeleaf之后 该controller失效
 * @date  2019/4/9 20:13
 * @param  * @Param: null
 * @return
**/
@Controller
@RequestMapping("/indexController")
public class IndexController {

    @RequestMapping("/index")
    public ModelAndView index(){
        ModelAndView mv = new ModelAndView("/index");
        List<IndexDomain> list = createIndexList();
        mv.addObject("mercuryList",list);
        return mv;
    }

    private List<IndexDomain> createIndexList(){
        List<IndexDomain> list = new ArrayList<>();
        IndexDomain i1 = new IndexDomain("石婷婷",18,"www.baidu.com");
        IndexDomain i2 = new IndexDomain("mercury",18,"www.alibaba.com");
        IndexDomain i3 = new IndexDomain("石婷婷",18,"www.baidu.com");
        list.add(i1);
        list.add(i2);
        list.add(i3);
        return list;
    }
}
